classdef LogUtilityFunction < handle
    
    properties
        epsilon
        xi
    end
    
    methods
        
        function self = LogUtilityFunction(epsilon, xi)
            self.epsilon = epsilon;
            self.xi = xi;
        end

        
        function out = U(self,c,l)
        % utility function
            out = log(c)-1/self.xi.*l.^(1+1/self.epsilon)./(1+1/self.epsilon);
            out(out<-1e6) = -1e6;
            out(out>1e6) = 1e6;
        end

        
        function out = dUdl(self,l)
            out = -1/self.xi.*l.^(1/self.epsilon);
        end

        
        function out = mtax(self,l,w)
            out = 1+self.dUdl(l)./w;
        end

        
        function out = Udot(self,l,w)
            out = -self.dUdl(l).*l./w;
        end

        
        function out = c(self,V,l)
        % consumption as function of indirect utility V and labor
        % supply l
            out = exp(V+1/self.xi.*l.^(1+1/self.epsilon)./(1+1/self.epsilon));
            out(out<-1e6) = -1e6;
            out(out>1e6) = 1e6;
        end

     
        
    end
end